/*
 * Copyright (c) 2005, 2020, Jin Lin All rights reserved.
 * Jin Lin PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 */
package aco.entity.dobject;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述 代价.
 *
 * @author Jin Lin
 * @created 2019 -06-30 13:04:20
 */
public class Cost {

    /**
     * 任务列表.
     */
    private List<Task> tasks;

    /**
     * 描述 任务长度.
     *
     * @return the long
     * @author Jin Lin
     * @created 2019 -06-30 13:20:13 Length of tasks long.
     */
    public Long lengthOfTasks() {
        return Long.parseLong(getTasks().size() + "");
    }

    /**
     * 描述 创建随机任务,生成随机代价并代价（耗时）矩阵.
     *
     * @param length the length
     * @param min    the min
     * @param max    the max
     * @author Jin Lin
     * @created 2019 -06-30 15:11:20 Init random tasks.
     */
    public void initRandomTasks(Long length, Long min, Long max, List<Node> nodes) {
        List<Task> tasks = new ArrayList<>();
        for (Long i = 0L; i < length; i++) {
            Task task = new Task(
                    new Double(Math.random() * (max - min) + min).longValue(), nodes);
            tasks.add(task);
        }
        setTasks(tasks);
    }

    //=================================================================

    /**
     * Instantiates a new Cost.
     */
    public Cost() {
    }

    /**
     * Instantiates a new Cost.
     *
     * @param tasks the tasks
     */
    public Cost(List<Task> tasks) {
        this.tasks = tasks;
    }

    /**
     * 描述 Gets tasks.
     *
     * @return the tasks
     * @author Jin Lin
     * @created 2019 -06-30 13:05:54
     */
    public List<Task> getTasks() {
        return tasks;
    }

    /**
     * 描述 Sets tasks.
     *
     * @param tasks the tasks
     * @author Jin Lin
     * @created 2019 -06-30 13:05:54
     */
    public void setTasks(List<Task> tasks) {
        this.tasks = tasks;
    }


}
